import sys
sys.path.append('..')
from Function.readdatafunction import readdata
from Function.CNN import SimpleCNN
from Function.loss import softmax
from Function.accuracy import comouteaccuracy
from Function.drawPicture import drawPicture
import torch


net = SimpleCNN(num_classes=9, in_channels=200)
PATH = './model/India/CNN_India.pt'
net.load_state_dict(torch.load(PATH))

Xtrain, Ytrain, X, Y, res = readdata("../dataset/Indian_pines/Indian_pines_corrected.mat", 'indian_pines_corrected',
                                        "../dataset//Indian_pines/Indian_pines_gt.mat", "indian_pines_gt",
                                        17, 200, 9, "CNN")
X = torch.from_numpy(X)
Y = torch.from_numpy(Y)
y_pred = softmax(net(X)).argmax(dim=1)

comouteaccuracy(y_pred.numpy(), Y.numpy())
drawPicture(y_pred, res, 145, 145, './Picture/India', 'CNN')